<template>
    <div>
        <p>编辑字典</p>
        <el-form ref="form" :model="form" label-width="80px">
            <el-form-item label="字典名称">
                <el-input v-model="form.dicname"></el-input>
            </el-form-item>
            <el-form-item label="字典编码">
                <el-input disabled v-model="form.code"></el-input>
            </el-form-item>
            <el-form-item label="字典描述">
                <el-input v-model="form.desc"></el-input>
            </el-form-item>
            <el-form-item label="字典排序">
                <el-input v-model="form.sort"></el-input>
            </el-form-item>
            <el-form-item label="字典状态">
                <el-select v-model="form.status" placeholder="请选择活动区域">
                    <el-option label="选择状态" value="0"></el-option>
                    <el-option label="启用" value="1"></el-option>
                    <el-option label="未启用" value="2"></el-option>
                </el-select>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
import { selectDict1ById } from '@/api/systemManager'
import bus from '@/components/common/bus';
export default {
    data() {
        return {
            form: {}
        };
    },
    props: ['id', 'isSon'],
    mounted() {
        this.getData()
    },
    methods: {
        async getData() {
            let result = await selectDict1ById({ id: this.id })
            if (result.code == 200) {
                this.form = result.data
                this.form.status = String(this.form.status)
            }
        }
    },
    watch: {
        form: {
            immediate: true,
            handler(val) {
                if (this.isSon) {
                    bus.$emit('getForm2', val)
                } else {
                    bus.$emit('getForm', val)
                }
            }
        }
    }
};
</script>

<style  lang="less" scoped></style>
